package com.itheima.ydd.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.ydd.common.R;
import com.itheima.ydd.dto.BaseInfoDto;
import com.itheima.ydd.pojo.*;
import com.itheima.ydd.service.*;
import com.itheima.ydd.service.impl.IndexServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("index")
@Slf4j
public class IndexController {

    @Autowired
    private IndexService indexService;

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private SysConfigService sysConfigService;

    /**
     * 登录
     *
     * @param sysUser
     * @return
     */
    @PostMapping("login")
    public ResponseEntity<R<Map<String,String>>> login(@RequestBody SysUser sysUser) {


        return indexService.login(sysUser);
    }

    /**
     * 获取系统配置
     *
     * @return
     */
    @GetMapping("getConfig")
    public ResponseEntity<R<List<SysConfig>>> getConfig() {
        return indexService.getConfig();
    }

    /**
     * 主页信息统计
     *
     * @return
     */
    @GetMapping("baseInfo")
    public ResponseEntity<R<BaseInfoDto>> baseInfo() {
        return indexService.baseInfo();
    }

    /**
     * 页面所有的用户信息回显
     * @return
     */
    @PostMapping("profile")
    public ResponseEntity<R<UserManager>> profile(@RequestHeader("x-token") String token) {
        return indexService.profile(token);
    }

    //GET /index/new



}
